import 'package:flutter/material.dart';
import 'package:ball_lion/resources/colours.dart';
import 'package:umeng_apm_sdk/umeng_apm_sdk.dart';
import 'package:ball_lion/widgets/base/wqs_text.dart';

class DataLeftList extends StatelessWidget {
  final List<String> titles;
  final int selectIndex;
  final Function(int) onSelectIndex;
  DataLeftList(this.titles, this.selectIndex, this.onSelectIndex, {super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
        color: Colours.greyF5F7FA,
        width: 80,
        child: MediaQuery.removePadding(
            context: context,
            removeTop: true,
            child: ListView.builder(
                controller: ApmScrollController(),
                itemCount: titles.length,
                itemBuilder: (context, index) => GestureDetector(
                    behavior: HitTestBehavior.opaque,
                    onTap: () => onSelectIndex(index),
                    child: Stack(children: [
                      Container(
                        height: 60,
                        padding: const EdgeInsets.symmetric(horizontal: 4),
                        color: selectIndex == index
                            ? Colours.B1
                            : Colours.transparent,
                        alignment: Alignment.center,
                        child: QsText(
                          titles[index],
                          textAlign: TextAlign.center,
                          fontSize: 13,
                          fontWeight: selectIndex == index
                              ? FontWeight.w500
                              : FontWeight.w400,
                          color: selectIndex == index ? Colours.B6 : Colours.N9,
                        ),
                      ),
                      Visibility(
                          visible: selectIndex == index,
                          child: Positioned(
                              left: 0,
                              top: 18,
                              bottom: 18,
                              child: Container(
                                  width: 3,
                                  height: 24,
                                  decoration: const BoxDecoration(
                                      color: Colours.B6,
                                      borderRadius: BorderRadius.horizontal(
                                          right: Radius.circular(3))))))
                    ])))));
  }
}
